/**
 * 
 */
package org.mspring.crm.entity.dataimport;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author Gao Youbo
 * @since Feb 26, 2012
 */
@Entity
@javax.persistence.Table(name = "dataimport_table_column")
public class TableColumn implements Serializable {
    private Integer id;
    private String name;
    private String type;
    private boolean isPK;
    private boolean isNull;
    private boolean isAutoNumber;
    private String defaultValue;
    private Table table;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "name", length = 100)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "type", length = 100)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Column(name = "is_pk")
    public boolean isPK() {
        return isPK;
    }

    public void setPK(boolean isPK) {
        this.isPK = isPK;
    }

    @Column(name = "is_null")
    public boolean isNull() {
        return isNull;
    }

    public void setNull(boolean isNull) {
        this.isNull = isNull;
    }

    @Column(name = "is_autonumber")
    public boolean isAutoNumber() {
        return isAutoNumber;
    }

    public void setAutoNumber(boolean isAutoNumber) {
        this.isAutoNumber = isAutoNumber;
    }

    @Column(name = "default_value", length = 200)
    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = Table.class)
    @JoinColumn(name = "table_id", nullable = false)
    public Table getTable() {
        return table;
    }

    public void setTable(Table table) {
        this.table = table;
    }
}
